
function request() {

    if (!mailText.text.trim()) {
        dialog.message("邮箱不可为空!");
        return
    }


    nav.initializeTask(0,2, "正在发送邮箱验证邮件......")
    nav.openTask("找回密码");

    http.get("/member.json?t=m1", {
                          mail: mailText.text.trim()

                      }, recResult)

    nav.value++
}
function recResult(json) {
        nav.value = nav.maximumValue
    if (json.error) {
            dialog.toast(json.error.description)
        return
    }

    dialog.toast("邮件发送成功，请登录邮箱查收邮件")

    stacklayout.currentIndex = 1
}


function codeRequest() {
    if (!codeText.text.trim()) {
        dialog.message("验证码不可为空!");
        return
    }

    nav.maximumValue = 2
    nav.value = 0
    nav.description = "正在核对验证码......"
 dialog.task("核对验证码", nav);

    http.get("/member.json?t=m2", {
                          code: codeText.text.trim(),
                      }, codeResult)

    nav.value++
}

function codeResult(json) {
    nav.value = nav.maximumValue
if (json.error) {
        dialog.toast(json.error.description)
    return
}


stacklayout.currentIndex = 2
}


function changePass() {
    if (passText.text.trim().length < 6)
    {
        dialog.message("密码不能小于6位!");
        return;
    }

    if (passText.text.trim() != pass2Text.text.trim()) {
        dialog.message("两次密码不一致!");
        return;
    }

    nav.maximumValue = 2
    nav.value = 0
    nav.description = "正在发送邮箱验证邮件......"
 dialog.task("邮件发送", nav);

    http.put("/member.json?t=r", {code: codeText.text.trim()}, {
                          password: passText.text.trim(),
                      }, passResult)

    nav.value++

}

function passResult(json) {
    nav.value = nav.maximumValue
if (json.error) {
        dialog.toast(json.error.description)
    return
}


 contentArea.navigate("../qml/LoginNavigator.qml");
}
